#include "gtest/gtest.h"
#include "sort/merge.hpp"
#include "common.hpp"

using namespace yfwz100::fundamental;

TEST(merge, unordered)
{
  int a[] = {9, 3, 4, 2, 4, 1, 3, 5};
  merge_sort(a, 8);
  ASSERT_ORDER(a, 0, 8);
  int sorted_a[] = {1, 2, 3, 3, 4, 4, 5, 9};
  ASSERT_EQARR(a, sorted_a, 8);
}

TEST(merge, random)
{
  int max_len = 100;
  int a[max_len];
  srand(13);
  for (int i = 0; i < max_len; i ++) {
    a[i] = (int) (rand() * max_len + 1);
  }
  merge_sort(a, max_len);
  ASSERT_ORDER(a, 0, max_len);
}
